home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / PLOT.LI3 < prev    next >
Text File  |  1994-07-20  |  598b  |  22 lines

  1. #    plot(y,x)
  2. #    plots a function of y=y(x)
  3. #    on xy-plane by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
  4. #    e.g. plot(sin(x),x)
  5.  
  6. plot(y_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
  7.     graph,
  8.     dx:=(xmax-xmin)/getmaxx,
  9.     dy:=(ymax-ymin)/getmaxy,
  10.     xstep:=dx*10,
  11.     axis(xmin,xmax,ymin,ymax),
  12.     setcolor(colorno(yellow)),
  13.     moveto(0,getmaxy-(subs(y,x=xmin)-ymin)/dy),
  14.     do( lineto((x-xmin)/dx,getmaxy-(y-ymin)/dy),
  15.     x,xmin,xmax,xstep),
  16.     numeric:=off,
  17.     readchar,
  18.     text,
  19.     local(dx,dy,xstep))
  20. plot(y_, x_, xmin_, xmax_) := plot(y,x,xmin,xmax,-5,5)
  21. plot(y_, x_) := plot(y,x,-5,5,-5,5)
  22.